package com.aaa.singleton;

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader;
import org.junit.Test;

import java.util.PrimitiveIterator;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: TODO
 * @date 2022/11/7
 */
public class Singleton1Test {
    //演示
        //如果在多线程的情况下，可能获取的对象会被创建多次
    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Singleton1.getInstance());
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Singleton1.getInstance());
            }
        }).start();
    }
    /*这种线程的安全问题我们可以使用方法加锁来解决*/
}
